//
//  LJJOrderAddressView.m
//  shopTest
//
//  Created by 梁佳佳 on 2016/11/22.
//  Copyright © 2016年 梁佳佳. All rights reserved.
//

#import "LJJOrderAddressView.h"

@interface LJJOrderAddressView ()

@property (strong, nonatomic) UILabel *addressLabel;    /** 地址 **/
@property (strong, nonatomic) UILabel *phoneLabel;    /** 手机号 **/
@property (strong, nonatomic) UIImageView *addressImageView;    /** 图片 **/
@property (strong, nonatomic) UIButton *backButton;    /** 背景按钮 **/

@end

@implementation LJJOrderAddressView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self addSubview:self.backButton];
        [self addSubview:self.addressLabel];
        [self addSubview:self.phoneLabel];
        [self addSubview:self.addressImageView];
    }
    return self;
}
- (void)layoutSubviews{
    [super layoutSubviews];
    __weak typeof (self) weakSelf = self;
    [_backButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(weakSelf).with.insets(UIEdgeInsetsMake(0, 0, 0, 0));
    }];
    [_addressImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(20, 20));
        make.centerY.equalTo(weakSelf.mas_centerY);
        make.left.equalTo(weakSelf.mas_left).offset(8);
    }];
    [_addressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.mas_top).offset(10);
        make.left.equalTo(weakSelf.addressImageView.mas_right).offset(10);
        make.right.equalTo(weakSelf.mas_right).offset(-10);
        make.height.equalTo(@30);
    }];
    [_phoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.addressImageView.mas_right).offset(10);
        make.right.equalTo(weakSelf.mas_right).offset(-10);
        make.bottom.equalTo(weakSelf.mas_bottom).offset(-10);
        make.height.equalTo(@15);
    }];
}

#pragma mark -
#pragma mark - lazy method
- (UILabel *)addressLabel
{
    if (!_addressLabel) {
        _addressLabel = [[UILabel alloc] init];
        _addressLabel.text = @"上海市闵行区联航路1188号";
        _addressLabel.textColor = [UIColor grayColor];
        _addressLabel.font = [UIFont systemFontOfSize:13.0];
    }
    return _addressLabel;
}
- (UILabel *)phoneLabel
{
    if (!_phoneLabel) {
        _phoneLabel = [[UILabel alloc] init];
        _phoneLabel.text = @"13666666666";
        _phoneLabel.textColor = [UIColor grayColor];
        _phoneLabel.font = [UIFont systemFontOfSize:13.0];
    }
    return _phoneLabel;
}
- (UIImageView *)addressImageView
{
    if (!_addressImageView) {
        _addressImageView = [[UIImageView alloc] init];
        _addressImageView.image = [UIImage imageNamed:@"位置"];
    }
    return _addressImageView;
}
- (UIButton *)backButton
{
    if (!_backButton) {
        _backButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _backButton.highlighted = NO;
        [_backButton setImage:[UIImage imageNamed:@"地址背景"] forState:UIControlStateNormal];
    }
    return _backButton;
}

@end
